import request from "@/axios"

let backUrl = process.env.VUE_APP_PATH+'/login'

let backUri = process.env.VUE_APP_PATH+'/login/success'

//获取返回code的地址
export function getCodeUrl() {
    let url ='/api/login/code/url'
    let params = {backUrl}
    return request.get(url,{params})
}

export function getCodeUri() {
    let url ='/api/login/code/uri'
    let params = {backUri}
    return request.get(url,{params})
}



//微信登录
export function wxLogin(code,topUserId,register) {
    let url ='/api/login/wx'
    let data = {code,topUserId,register}
    return request.post(url,data)
}

//手机号验证码登录
export function phoneLogin(phone,captcha,topUserId,register,name,avatar,unionId,openId) {
    let url ='/api/login/phone'
    let data = {phone,captcha,topUserId,register,name,avatar,unionId,openId}
    data.Loading = true
    return request.post(url,data)
}

export function testLogin(userId) {
    let url = '/api/login/test'
/*    request.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'*/
    const data = {userId}
    return request.post(url,data)
}